package com.project.entity.article;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.project.dao.annotation.Between;
import com.project.dao.annotation.Like;
import com.project.entity.BaseEntity;
import com.project.entity.enumcommon.PublishStatusEnum;

@Entity
@Table(name="B_ARTICLE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@DynamicInsert
@DynamicUpdate
public class Article extends BaseEntity{
	
	/**
     * 
     */
    private static final long serialVersionUID = -6907567849312641240L;

    @Column
	private String title;//标题
	
	@Column(name="category_id")
	private Long categoryId;//类别id
	
	@Column(name="label_id")
	private Long labelId;//标签id
	
	@Column(name="publish_time")
	@Between
	private Date publishTime;//发布时间 publishTimeEnd
	
	@Column(name="page_view")
	@Between(type="Long")
	private Long pageView;//访问量
	
	@Column(name="content")
	private String content;//内容
	
	@Column(name="qrcode_url")
	private String qrcodeUrl;//二维码图片地址
	
	@Column(name="cover_pic_url")
	private String coverPicUrl;//封面图片url
	
	@Column(name="publish_status")
	@Enumerated(EnumType.STRING)
	private PublishStatusEnum publishStatus;//发布状态(N:未发布 P:已发布)
	
	@Column(name="create_user")
	private String createUser;//创建人
	
	@Column(name="create_time")
	private Date createTime;//创建时间
	
	@Column(name="update_user")
	private String updateUser;//修改人
	
	@Column(name="update_time")
	private Date updateTime;//修改时间
	
	@OneToOne(fetch=FetchType.LAZY,cascade=CascadeType.REFRESH)
	@JoinColumn(name="category_id",updatable=false,insertable=false)
	private Category category;
	
	@OneToOne(fetch=FetchType.LAZY,cascade=CascadeType.REFRESH)
	@JoinColumn(name="label_id",updatable=false,insertable=false)
	private Category label;

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Long getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}

	public Long getLabelId() {
		return labelId;
	}

	public void setLabelId(Long labelId) {
		this.labelId = labelId;
	}

	public Long getPageView() {
		return pageView;
	}

	public void setPageView(Long pageView) {
		this.pageView = pageView;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getQrcodeUrl() {
		return qrcodeUrl;
	}

	public void setQrcodeUrl(String qrcodeUrl) {
		this.qrcodeUrl = qrcodeUrl;
	}

	public String getCoverPicUrl() {
		return coverPicUrl;
	}

	public void setCoverPicUrl(String coverPicUrl) {
		this.coverPicUrl = coverPicUrl;
	}
	
	public String getCreateUser() {
		return createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getPublishTime() {
		return publishTime;
	}

	public void setPublishTime(Date publishTime) {
		this.publishTime = publishTime;
	}

	public PublishStatusEnum getPublishStatus() {
		return publishStatus;
	}

	public void setPublishStatus(PublishStatusEnum publishStatus) {
		this.publishStatus = publishStatus;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public Category getLabel() {
		return label;
	}

	public void setLabel(Category label) {
		this.label = label;
	}
	
}
